<%--
  Created by IntelliJ IDEA.
  User: 13181
  Date: 2019/8/31
  Time: 22:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
<head>
    <title>文件</title>
    <script type="text/javascript" src="${requestPath}/resources/js/jquery-3.4.1.js"></script>
</head>
<body>
<div align="center">
    <table border="1" width="400">
        <tr>
            <th>文件编号</th>
            <th>文件地址</th>
            <th>文件名</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${fileList}" var="file">
        <tr>
            <td>${file.fileId}</td>
            <td>${file.realPath}</td>
            <td>${file.originalName}</td>
            <td>
                <a href="/downloadFile?originalName=${file.originalName}">文件下载</a>
                <a href="#" onclick="deleteFile('${file.fileId}')"> 删除</a>
            </td>
        </tr>
        </c:forEach>
    </table>

</div>
<script>
    function deleteFile(fileId) {

        var flag =confirm("是否删除该文件？");
        if(!flag){
            return;
        }
        $.ajax(
            {
                url:"${requestPath}/delFileByFileId?fileId="+fileId,
                async:false,
                type:'get',
                success:function (data) {
                    if(data.flag){
                        alert("删除成功！");
                        location.href="${requestPath}/query";
                    }
                    }

            }
        );


    }
</script>
</body>
</html>
